﻿/* 2011/11/28 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Cosmos.Shortcuts;

namespace PictureManager
{
    /// <summary>
    /// Capture a mouse gesture in a form.
    /// </summary>
    public partial class CaptureMouseGestureForm : Form
    {
        MouseGestureParser _parser;

        public CaptureMouseGestureForm()
        {
            InitializeComponent();

            Properties.Settings settings = Properties.Settings.Default;
            _parser = new MouseGestureParser(settings.MouseGestureColor, settings.MouseGestureWidth);
        }

        private void CaptureMouseGestureForm_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Left)
                _parser.GestureMouseDown(sender, e);
        }

        private void CaptureMouseGestureForm_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Left)
                _parser.GestureMouseMove(sender, e);
        }

        private void CaptureMouseGestureForm_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Left)
                _parser.GestureMouseUp(sender, e);

            Close();
        }

        /// <summary>
        /// Gets the mouse gesture captured in this form.
        /// </summary>
        public MouseGesture Gesture
        {
            get { return _parser.Gesture; }
        }
    }
}
